package com.adou.d16.bio;

import java.io.*;

public class BITest1 {
    public static void main(String[] args) {
        try(// 读取
            InputStream is = new FileInputStream("D:\\file\\image.jpg");

            // 写入
            OutputStream os = new FileOutputStream("C:\\data\\image_bak1.jpg");) {

            // 包装缓冲流
             InputStream bis = new BufferedInputStream(is, 8192*2);
             BufferedOutputStream bos = new BufferedOutputStream(os, 8192*2);


            // 创建一个字节数组
            byte[] buffer = new byte[1024];// 1kb

            // 读取多少写入多少
            int len; // 记住读取多少字节
            while((len=bis.read(buffer))  != -1 ) { // 桶
                bos.write(buffer, 0, len);
            }
            System.out.println("复制完成");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
